<template>
  <div class="app">
    <div v-if="isShowEdit">
      <input type="text" v-model="editValue" ref="inp" />
      <button>确认</button>
    </div>
    <div v-else>
      <span>{{ title }}</span>
      <button @click="handleEdit">编辑</button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      title: '大标题',
      isShowEdit: false,
      editValue: '',
    }
  },
  methods: {
   handleEdit(){
    //1.显示输入框(异步DOM更新)
    this.isShowEdit = true
    //2.让输入康获取焦点
    this.$nextTick(()=>{
      console.log(this.$refs.inp);
      this.$refs.inp.focus()
    })
 
   }
  },
}
</script>

<style>
</style>